package com.hd.tiyu.yuejian.Fragment;


import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.hd.tiyu.yuejian.Activity.KeVideoActivity;
import com.hd.tiyu.yuejian.Activity.MasterActivity;
import com.hd.tiyu.yuejian.Adapter.DashiketangAdapter;
import com.hd.tiyu.yuejian.Adapter.HuodongAdapter;
import com.hd.tiyu.yuejian.JavaBean.Activity;
import com.hd.tiyu.yuejian.JavaBean.Dashi;
import com.hd.tiyu.yuejian.JavaBean.Master;
import com.hd.tiyu.yuejian.Model.ListsModel;
import com.hd.tiyu.yuejian.R;
import com.squareup.picasso.Picasso;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


/**
 * Created by Administrator on 2017/10/9.
 */

public class KetangFragment extends Fragment{
    private View view;
    private RecyclerView recyclerView;
    Dashi data;
    private String id;
    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.ketangtab,container,false);
        Bundle bundle=getArguments();
        id=bundle.getString("id");
        initView();
        initEvent();
        initData();
        return view;
    }
    private void initView() {

        recyclerView=view.findViewById(R.id.ketang_re);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }
    private void initData() {
        ListsModel listsmodel=new ListsModel();
        Call<Dashi>call=listsmodel.getDashiketang(id);
        call.enqueue(new Callback<Dashi>() {
            @Override
            public void onResponse(Call<Dashi> call,Response<Dashi> response) {
                data=response.body();
                if(data!=null) {
                    List<Dashi.MvideoBean> video = data.getMvideo();
                    recyclerView.setAdapter(new DashiketangAdapter(getActivity(), video));
                }
            }
            @Override
            public void onFailure(Call<Dashi> call,Throwable t) {

            }
        });
    }
    private void initEvent() {

    }



}
